package main

import (
	"fmt"
	"log"
	"net/http"
)

type WelcomeHandler struct {
	language string
}

func (w WelcomeHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
	fmt.Fprintf(writer, "%s", w.language)
}

func main() {
	mux := http.NewServeMux()
	mux.Handle("/cn", WelcomeHandler{"欢迎一起来学GO Web!"})
	mux.Handle("/en", WelcomeHandler{"welcome you, let's,let's learn go web"})

	server := http.Server{
		Addr:    ":8082",
		Handler: mux,
	}

	if err := server.ListenAndServe(); err != nil {
		log.Fatal(err)
	}
}
